From d5a44c19ceeda9927a0ad6eb02bef4ed08128f0a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 9 Nov 2023 16:03:29 -0800 Subject: rename fund name to id --- src/routes/(app)/fund/[id]/withdraw/+page.server.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/routes/(app)/fund/[id]/withdraw/+page.server.js (limited to 'src/routes/(app)/fund/[id]/withdraw/+page.server.js') diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.server.js b/src/routes/(app)/fund/[id]/withdraw/+page.server.js new file mode 100644 index 00000000..476149f2 --- /dev/null +++ b/src/routes/(app)/fund/[id]/withdraw/+page.server.js @@ -0,0 +1,20 @@ +import { fail, json, redirect } from '@sveltejs/kit'; +import { fd, auth, post } from '$lib/utils'; + +export async function load({ parent }) { + let { user } = await parent(); + if (!user) throw redirect(307, '/register'); +} + +export const actions = { + default: async ({ cookies, request }) => { + let body = await fd(request); + try { + await post('/take', body, auth(cookies)); + } catch (e) { + return fail(400, { message: e.message }); + } + + throw redirect(307, `/fund/${body.id}`); + } +}; -- cgit v1.2.3